import { CommonService } from 'src/common/common.service';
import { Controller, Post, UploadedFile, UseInterceptors } from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import { ApiProperty, ApiTags, ApiConsumes, ApiBody } from '@nestjs/swagger';
import { IsNotEmpty } from 'class-validator';
class FileUploadDto {
  @ApiProperty({ type: 'string', format: 'binary' })
  @IsNotEmpty()
  file: any;
}
@Controller('common')
@ApiTags('common')
export class CommonController {
  constructor(private CommonService: CommonService) {}

  @Post('uploadfile')
  @UseInterceptors(FileInterceptor('file'))
  @ApiBody({
    description: 'List of cats',
    type: FileUploadDto,
  })
  // @ApiProperty({type:'file'})
  @ApiConsumes('multipart/form-data')
  async uploadFile(@UploadedFile() file: Express.Multer.File) {
       
  return  await this.CommonService.uploadFile(file)
  }
}
